/**
 * 
 */
package org.statewalker.parser.xhtml.validator;

import java.util.HashSet;

import org.statewalker.parser.xhtml.grammar.TopicGrammar;
import org.statewalker.parser.xhtml.grammar.XHTMLDict;
import org.statewalker.validator.Validator;
import org.statewalker.validator.ValidatorGrammarConfig;

public class TopicValidatorFactory extends XHTMLValidatorFactory {

    private TopicGrammar fTopicGrammar;

    public TopicValidatorFactory() {
        super();
    }

    @Override
    protected void configureDictionaries() {
    }

    @Override
    protected void configureTransitions(ValidatorGrammarConfig config) {
        fSpaceContainers = new HashSet<String>();
        fTopicGrammar = new TopicGrammar(config) {
            @Override
            protected void markKeyAsAcceptingSpaces(String key) {
                fSpaceContainers.add(key);
            }
        };
        fXhtmlGrammar = fTopicGrammar;
        fTopicGrammar.init();
        // We don't allow to put spaces directly in the body...
        fSpaceContainers.remove(XHTMLDict.BODY);
    }

    public TopicGrammar getTopicGrammar() {
        return fTopicGrammar;
    }

    @Override
    public Validator newValidator() {
        return new TopicValidator(this);
    }

}